/**
 * Created by Administrator on 2017/7/6.
 */
$(function(){
    var hh = 1;
    $(document).keydown(function(){

        if(hh==1){
            $(".armleftup").css({"animation":"fightarmleftup 1s linear","animation-fill-mode":"forwards"} );
            $(".armleftdown").css({"animation":"fightarmleftdown 1s linear","animation-fill-mode":"forwards"} );
            $(".armrightup").css({"animation":"fightarmrightup 1s linear","animation-fill-mode":"forwards"} );
            $(".armrightdown").css({"animation":"fightarmrightdown 1s linear","animation-fill-mode":"forwards"} );
            $(".legrightup").css({"animation":"fightlegrightup 1s linear","animation-fill-mode":"forwards"} );
            $(".legrightdown").css({"animation":"fightlegrightdown 1s linear","animation-fill-mode":"forwards"} );
            hh++;
        }

/*
        $(".armleftup").css({"left":"30px","top":"10px","transform":"rotate(-67deg)"});
        $(".armleftdown").css({"left":"60px","top":"-8px","transform":"rotate(-150deg)"});
        $(".armrightup").css({"right":"-24px","top":"0px","transform":"rotate(-90deg)"});
        $(".armrightdown").css({"right":"-43px","top":"-32px","transform":"rotate(-175deg)"});
        $(".legrightup").css({"left": "25px","top": "99px","transform": "rotate(-40deg)"});
        $(".legrightdown").css({"right":"-43px","top":"148px","transform":"rotate(-8deg)"});*/
    });
    var num =1;
        $(window).keydown(function(event){
            /*var fightlegright = $(".legrightdown").css({"right":"-43px","top":"148px","transform":"rotate(-8deg)"});
            var legright = $(".legrightdonw");*/

            var go = num*(-100);
            if(event.keyCode==39){

                if( num%2==0){
                    $(".legrightup").css({"animation":"movelegrightup 1s linear","animation-fill-mode":"forwards"} );
                    $(".legrightdown").css({"animation":"movelegrightdown 1s linear","animation-fill-mode":"forwards"} );
                    $(".legleftup").css({"animation":"movelegleftup 1s linear","animation-fill-mode":"forwards"} );
                    $(".legleftdown").css({"animation":"movelegleftdown 1s linear","animation-fill-mode":"forwards"} );
                    $(".world").css("right","");
                    $(".world").animate({"left":go+"px"},1000);
                }else{
                    $(".legrightup").css({"animation":"movelegrightup2 1s linear","animation-fill-mode":"forwards"} );
                    $(".legrightdown").css({"animation":"movelegrightdown2 1s linear","animation-fill-mode":"forwards"} );
                    $(".legleftup").css({"animation":"movelegleftup2 1s linear","animation-fill-mode":"forwards"} );
                    $(".legleftdown").css({"animation":"movelegleftdown2 1s linear","animation-fill-mode":"forwards"} );
                    $(".world").css("right","");
                    $(".world").animate({"left":go+"px"},1000);
                }
            }
            if(event.keyCode==37){
                if( num%2==0){
                    $(".legrightup").css({"animation":"movelegrightup 1s linear","animation-fill-mode":"forwards"} );
                    $(".legrightdown").css({"animation":"movelegrightdown 1s linear","animation-fill-mode":"forwards"} );
                    $(".legleftup").css({"animation":"movelegleftup 1s linear","animation-fill-mode":"forwards"} );
                    $(".legleftdown").css({"animation":"movelegleftdown 1s linear","animation-fill-mode":"forwards"} );
                    $(".world").css("left","");
                    $(".world").animate({"right":go+"px"},1000);
                }else{
                    $(".legrightup").css({"animation":"movelegrightup2 1s linear","animation-fill-mode":"forwards"} );
                    $(".legrightdown").css({"animation":"movelegrightdown2 1s linear","animation-fill-mode":"forwards"} );
                    $(".legleftup").css({"animation":"movelegleftup2 1s linear","animation-fill-mode":"forwards"} );
                    $(".legleftdown").css({"animation":"movelegleftdown2 1s linear","animation-fill-mode":"forwards"} );
                    $(".world").css("left","");
                    $(".world").animate({"right":go+"px"},1000);
                }
            }
                if(event.keyCode==65){
                    console.log(num);
                    if(num%2==0){
                     $(".armleftup").css({"animation":"armleftuphit 0.2s linear","animation-fill-mode":"forwards"});
                        $(".armleftdown").css({"animation":"armleftdownhit 0.2s linear","animation-fill-mode":"forwards"});
                     }else{
                     $(".armleftup").css({"animation":"armleftuphit2 0.2s linear","animation-fill-mode":"forwards"})
                        $(".armleftdown").css({"animation":"armleftdownhit2 0.2s linear","animation-fill-mode":"forwards"})
                     }
                }
            if(event.keyCode==68){
                console.log(num);
                if(num%2==0){
                    $(".armrightup").css({"animation":"armrightuphit 0.2s linear","animation-fill-mode":"forwards"});
                    $(".armrightdown").css({"animation":"armrightdownhit 0.2s linear","animation-fill-mode":"forwards"});
                }else{
                    $(".armrightup").css({"animation":"armrightuphit2 0.2s linear","animation-fill-mode":"forwards"});
                    $(".armrightdown").css({"animation":"armrightdownhit2 0.2s linear","animation-fill-mode":"forwards"});
                }
            }
            if(event.keyCode==83) {
                if (num % 2) {
                    $(".legleftup").css({"animation": "legleftuphit 0.2s linear", "animation-fill-mode": "forwards"});
                    $(".legleftdown").css({
                        "animation": "legleftdownhit 0.2s linear",
                        "animation-fill-mode": "forwards"
                    });
                }
                else {
                    $(".legleftup").css({"animation": "legleftuphit2 0.2s linear", "animation-fill-mode": "forwards"});
                    $(".legleftdown").css({
                        "animation": "legleftdownhit2 0.2s linear",
                        "animation-fill-mode": "forwards"
                    });
                }
            }
            num = num + 1;
            if(event.keyCode==90){
                $(".head").css({"animation":"headdie 1.0s linear","animation-fill-mode":"forwards"});
                $(".armleftup").css({"animation":"armleftupdie 0.6s linear","animation-fill-mode":"forwards"});
                $(".armleftdown").css({"animation":"armleftdowndie 1s linear","animation-fill-mode":"forwards"});
                $(".armrightup").css({"animation":"armrightupdie 1.2s linear","animation-fill-mode":"forwards"});
                $(".armrightdown").css({"animation":"armrightdowndie 0.5s linear","animation-fill-mode":"forwards"});
                $(".legleftup").css({"animation":"legleftupdie 0.8s linear","animation-fill-mode":"forwards"});
                $(".legleftdown").css({"animation":"legleftdowndie 0.6s linear","animation-fill-mode":"forwards"});
                $(".legrightup").css({"animation":"legrightupdie 0.5s linear","animation-fill-mode":"forwards"});
                $(".legrightdown").css({"animation":"legrightdowndie 0.3s linear","animation-fill-mode":"forwards"});
            }
            if(event.keyCode==90){
                $(".boss").css({"animation":"kill 0.4s linear","animation-fill-mode":"forwards"})
            }
        });
});